﻿<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
 
    <script type='text/html' template> 
        <input type='hidden' name='PID' value="{{ d.params.PID || '' }}"/>
    </script>   
    <div class='layui-form-item'>
        <label class='layui-form-label'>客服<span style="color:red">*</span></label>
        <div class='layui-input-inline'>
            <script type='text/html' template lay-done='layui.data.getSelSource(d.params,"CustomService");'>
                <select name='CustomService' id='CustomService' lay-verify='required' lay-search>
                    <option value=""></option>
                </select>
            </script>
        </div>
    </div>   
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" value="确认" class="layui-btn">
        </div>
    </div>
</div>
<style>
    .layui-upload-img {
        width: 100px;
        height: auto;
    }
</style>

<script type="text/javascript"> 
    var form, admin, $;
    layui.use(['form','admin','upload','laydate'], function () {
        form = layui.form;//required（必填项）phone（手机号）email（邮箱）url（网址）number（数字）date（日期）identity（身份证） 自定义值
        $ = layui.$;
        admin = layui.admin;
    });
    
    layui.data.getSelSource = function (d,sourceName) { 
         layui.use(['admin','form'], function () {
                $ = layui.$;
                form = layui.form;
                admin = layui.admin;

                if (sourceName == "CustomService") {
                    admin.req({
                        url: layui.setter.APIUrl + '/admin/userMgr/customerQuery2?storeid=' + d.PID, //实际使用请改成服务端真实接口
                        type: 'post',
                        done: function (res) {
                            layui.each(res.Data, function (index, eachdata) {
                                var strIsSel = '';
                                if (eachdata.Name == d.CustomService)
                                    strIsSel = "selected='selected'";
                                $("#CustomService").append("<option value='" + eachdata.PID + "' " + strIsSel + ">" + eachdata.UserName + "</option>");
                            });
                            form.render('select');
                        }
                    });
                }
        });
    }
    

</script>
